#pragma once

#include "QkBaseView.h"

class QkTreeItem;

class QkTocModel : public QAbstractItemModel
{
	Q_OBJECT
public:
	QkTocModel();
	~QkTocModel();

	QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
	QModelIndex parent(const QModelIndex &child) const;
	bool hasChildren (const QModelIndex & parent = QModelIndex() ) const;
	int rowCount(const QModelIndex &parent = QModelIndex()) const;
	int columnCount(const QModelIndex &parent = QModelIndex()) const;
	QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
	QVariant headerData(int section, Qt::Orientation orientation, int role) const;

protected:

private slots:
	void doLoadData();

private:
	QkTreeItem *itemFromIndex(const QModelIndex &index) const;
	void loadData();
	void on_data_loaded();

private:
	QkTreeItem *m_rootItem;
};
